package com.cskaoyan.bean;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

@Data
public class BasePageData<T> {
    Integer limit;
    Integer page;
    Integer pages;
    Integer total;
    List<T> list;

    public static <T> BasePageData ok(List<T> list) {
        PageInfo<T> userPageInfo = new PageInfo<T>(list);

        BasePageData<T> userBasePageData = new BasePageData<>();
        userBasePageData.setPage(userPageInfo.getPageNum());
        userBasePageData.setLimit(userPageInfo.getPageSize());
        userBasePageData.setPages(userPageInfo.getPages());
        userBasePageData.setTotal((int) userPageInfo.getTotal());
        userBasePageData.setList(list);

        return userBasePageData;
    }
}
